<?php
return [
    'module' => [
        'name' => 'article_category',
        'title' => '文章分类',
        'table' => 'article_categories',
    ],
    
    'fields' => [
        'id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '分类ID',
            'primary' => true,
            'auto_increment' => true,
            'nullable' => false,
            'required' => true,
        ],
        'name' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '分类名称',
            'required' => true,
            'nullable' => false,
            'rules' => 'required|unique:article_categories',
        ],
        'slug' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '分类标识',
            'required' => true,
            'nullable' => false,
            'rules' => 'required|unique:article_categories',
        ],
        'parent_id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '父级ID',
            'default' => 0,
        ],
        'order' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '排序',
            'default' => 0,
        ],
        'description' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '分类描述',
            'required' => false,
            'nullable' => true,
        ],
        'status' => [
            'type' => 'tinyint',
            'length' => 1,
            'comment' => '状态',
            'default' => 1,
            'options' => [
                0 => '禁用',
                1 => '启用'
            ],
        ],
        'created_at' => [
            'type' => 'timestamp',
            'comment' => '创建时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true
        ],
        'updated_at' => [
            'type' => 'timestamp',
            'comment' => '更新时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true,
            'extra' => 'ON UPDATE CURRENT_TIMESTAMP'
        ],
    ],
    
    'relations' => [
        'articles' => [
            'type' => 'hasMany',
            'model' => 'Article',
            'foreign_key' => 'category_id',
        ],
    ],
    
    'queries' => [
        'name' => ['like', '%?%'],
        'slug' => ['like', '%?%'],
        'status' => ['=', '?'],
    ],
]; 